package com.zline.foodraise.view;

import android.content.Context;
import android.widget.RelativeLayout;

import com.makeramen.roundedimageview.RoundedImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zline.foodraise.R;
import com.zline.foodraise.constant.Constant;
import com.zline.foodraise.listener.RecyclerItemClicked;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by heshantao on 15/7/6.
 * 动态中图片Item
 */
@EViewGroup(R.layout.dynamic_item_product_pics_item)
public class DynamicItemProPicturesItem extends RelativeLayout {
    private static final String LOG_TAG=DynamicItemProPicturesItem.class.getSimpleName();
    @ViewById(R.id.dynamic_item_product_pics_iv)
     RoundedImageView iv;
    ImageLoader imageLoader;
    RecyclerItemClicked itemClicked;
    int position;
    int parentPosition;

    public DynamicItemProPicturesItem(Context context) {
        super(context);
    }

    public void bind(String picUrl,int position,int parentPosition,DisplayImageOptions options) {
        this.position=position;
        this.parentPosition=parentPosition;
        imageLoader = ImageLoader.getInstance();
        imageLoader.displayImage(picUrl, iv, options);

    }

    @Click(R.id.dynamic_item_pics_item_rl)
    void onClick(){
        if(parentPosition<0){
            itemClicked.onRecyclerItemClicked(Constant.DYNAMIC_PICT_FLAG,position);
        }else{
            itemClicked.onRecyclerItemClicked(Constant.DYNAMIC_PICT_FLAG,position,parentPosition);
        }
    }

    public void setRecyclerItemClick(RecyclerItemClicked clicked){
        this.itemClicked=clicked;

    }
}
